home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 November / PCWorld_2006-11_cd.bin / system / innosetup / isetup-5.1.8.exe / {app} / Examples / CodeClasses.iss (.txt) < prev    next >
Encoding:
Inno Setup Script  |  2006-10-03  |  11.0 KB  |  256 lines

  1. ; -- CodeClasses.iss --
  2. ; This script shows how to use the WizardForm object and the various VCL classes.
  3. [Setup]
  4. AppName=My Program
  5. AppVerName=My Program version 1.5
  6. CreateAppDir=no
  7. DisableProgramGroupPage=yes
  8. DefaultGroupName=My Program
  9. UninstallDisplayIcon={app}\MyProg.exe
  10. WindowVisible=yes
  11. OutputDir=userdocs:Inno Setup Examples Output
  12. [Files]
  13. Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
  14. [Code]
  15. procedure ButtonOnClick(Sender: TObject);
  16. begin
  17.   MsgBox('You clicked the button!', mbInformation, mb_Ok);
  18. procedure FormButtonOnClick(Sender: TObject);
  19.   Form: TSetupForm;
  20.   OKButton, CancelButton: TButton;
  21. begin
  22.   Form := CreateCustomForm();
  23.   try
  24.     Form.ClientWidth := ScaleX(256);
  25.     Form.ClientHeight := ScaleY(256);
  26.     Form.Caption := 'TSetupForm';
  27.     Form.CenterInsideControl(WizardForm, False);
  28.     OKButton := TButton.Create(Form);
  29.     OKButton.Parent := Form;
  30.     OKButton.Width := ScaleX(75);
  31.     OKButton.Height := ScaleY(23);
  32.     OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
  33.     OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  34.     OKButton.Caption := 'OK';
  35.     OKButton.ModalResult := mrOk;
  36.     CancelButton := TButton.Create(Form);
  37.     CancelButton.Parent := Form;
  38.     CancelButton.Width := ScaleX(75);
  39.     CancelButton.Height := ScaleY(23);
  40.     CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
  41.     CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  42.     CancelButton.Caption := 'Cancel';
  43.     CancelButton.ModalResult := mrCancel;
  44.     CancelButton.Cancel := True;
  45.     Form.ActiveControl := OKButton;
  46.     if Form.ShowModal() = mrOk then
  47.       MsgBox('You clicked OK.', mbInformation, MB_OK);
  48.   finally
  49.     Form.Free();
  50.   end;
  51. procedure CreateTheWizardPages;
  52.   Page: TWizardPage;
  53.   Button, FormButton: TButton;
  54.   CheckBox: TCheckBox;
  55.   Edit: TEdit;
  56.   PasswordEdit: TPasswordEdit;
  57.   Memo: TMemo;
  58.   Lbl, ProgressBarLabel: TLabel;
  59.   ComboBox: TComboBox;
  60.   ListBox: TListBox;
  61.   StaticText: TNewStaticText;
  62.   ProgressBar: TNewProgressBar;
  63.   CheckListBox, CheckListBox2: TNewCheckListBox;
  64.   FolderTreeView: TFolderTreeView;
  65.   BitmapImage, BitmapImage2, BitmapImage3: TBitmapImage;
  66.   BitmapFileName: String;
  67.   RichEditViewer: TRichEditViewer;
  68. begin
  69.   { TButton and others }
  70.   Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');
  71.   Button := TButton.Create(Page);
  72.   Button.Width := ScaleX(75);
  73.   Button.Height := ScaleY(23);
  74.   Button.Caption := 'TButton';
  75.   Button.OnClick := @ButtonOnClick;
  76.   Button.Parent := Page.Surface;
  77.   CheckBox := TCheckBox.Create(Page);
  78.   CheckBox.Top := Button.Top + Button.Height + ScaleY(8);
  79.   CheckBox.Width := Page.SurfaceWidth;
  80.   CheckBox.Height := ScaleY(17);
  81.   CheckBox.Caption := 'TCheckBox';
  82.   CheckBox.Checked := True;
  83.   CheckBox.Parent := Page.Surface;
  84.   Edit := TEdit.Create(Page);
  85.   Edit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  86.   Edit.Width := Page.SurfaceWidth div 2 - ScaleX(8);
  87.   Edit.Text := 'TEdit';
  88.   Edit.Parent := Page.Surface;
  89.   PasswordEdit := TPasswordEdit.Create(Page);
  90.   PasswordEdit.Left := Page.SurfaceWidth - Edit.Width;
  91.   PasswordEdit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  92.   PasswordEdit.Width := Edit.Width;
  93.   PasswordEdit.Text := 'TPasswordEdit';
  94.   PasswordEdit.Parent := Page.Surface;
  95.   Memo := TMemo.Create(Page);
  96.   Memo.Top := Edit.Top + Edit.Height + ScaleY(8);
  97.   Memo.Width := Page.SurfaceWidth;
  98.   Memo.Height := ScaleY(89);
  99.   Memo.ScrollBars := ssVertical;
  100.   Memo.Text := 'TMemo';
  101.   Memo.Parent := Page.Surface;
  102.   Lbl := TLabel.Create(Page);
  103.   Lbl.Top := Memo.Top + Memo.Height + ScaleY(8);
  104.   Lbl.Caption := 'TLabel';
  105.   Lbl.AutoSize := True;
  106.   Lbl.Parent := Page.Surface;
  107.   FormButton := TButton.Create(Page);
  108.   FormButton.Top := Lbl.Top + Lbl.Height + ScaleY(8);
  109.   FormButton.Width := ScaleX(75);
  110.   FormButton.Height := ScaleY(23);
  111.   FormButton.Caption := 'TSetupForm';
  112.   FormButton.OnClick := @FormButtonOnClick;
  113.   FormButton.Parent := Page.Surface;
  114.   { TComboBox and others }
  115.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TComboBox and others');
  116.   ComboBox := TComboBox.Create(Page);
  117.   ComboBox.Width := Page.SurfaceWidth;
  118.   ComboBox.Parent := Page.Surface;
  119.   ComboBox.Style := csDropDownList;
  120.   ComboBox.Items.Add('TComboBox');
  121.   ComboBox.ItemIndex := 0;
  122.   ListBox := TListBox.Create(Page);
  123.   ListBox.Top := ComboBox.Top + ComboBox.Height + ScaleY(8);
  124.   ListBox.Width := Page.SurfaceWidth;
  125.   ListBox.Height := ScaleY(97);
  126.   ListBox.Parent := Page.Surface;
  127.   ListBox.Items.Add('TListBox');
  128.   ListBox.ItemIndex := 0;
  129.   StaticText := TNewStaticText.Create(Page);
  130.   StaticText.Top := ListBox.Top + ListBox.Height + ScaleY(8);
  131.   StaticText.Caption := 'TNewStaticText';
  132.   StaticText.AutoSize := True;
  133.   StaticText.Parent := Page.Surface;
  134.   ProgressBarLabel := TLabel.Create(Page);
  135.   ProgressBarLabel.Top := StaticText.Top + StaticText.Height + ScaleY(8);
  136.   ProgressBarLabel.Caption := 'TNewProgressBar';
  137.   ProgressBarLabel.AutoSize := True;
  138.   ProgressBarLabel.Parent := Page.Surface;
  139.   ProgressBar := TNewProgressBar.Create(Page);
  140.   ProgressBar.Left := ProgressBarLabel.Width + ScaleX(8);
  141.   ProgressBar.Top := ProgressBarLabel.Top;
  142.   ProgressBar.Width := Page.SurfaceWidth - ProgressBar.Left;
  143.   ProgressBar.Height := ProgressBarLabel.Height + ScaleY(8);
  144.   ProgressBar.Parent := Page.Surface;
  145.   ProgressBar.Position := 25;
  146.   { TNewCheckListBox }
  147.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TNewCheckListBox');
  148.   CheckListBox := TNewCheckListBox.Create(Page);
  149.   CheckListBox.Width := Page.SurfaceWidth;
  150.   CheckListBox.Height := ScaleY(97);
  151.   CheckListBox.Flat := True;
  152.   CheckListBox.Parent := Page.Surface;
  153.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  154.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, True, True, nil);
  155.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
  156.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  157.   CheckListBox2 := TNewCheckListBox.Create(Page);
  158.   CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + ScaleY(8);
  159.   CheckListBox2.Width := Page.SurfaceWidth;
  160.   CheckListBox2.Height := ScaleY(97);
  161.   CheckListBox2.BorderStyle := bsNone;
  162.   CheckListBox2.ParentColor := True;
  163.   CheckListBox2.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  164.   CheckListBox2.ShowLines := False;
  165.   CheckListBox2.WantTabs := True;
  166.   CheckListBox2.Parent := Page.Surface;
  167.   CheckListBox2.AddGroup('TNewCheckListBox', '', 0, nil);
  168.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, True, True, nil);
  169.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, False, True, nil);
  170.   { TFolderTreeView }
  171.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TFolderTreeView');
  172.   FolderTreeView := TFolderTreeView.Create(Page);
  173.   FolderTreeView.Width := Page.SurfaceWidth;
  174.   FolderTreeView.Height := Page.SurfaceHeight;
  175.   FolderTreeView.Parent := Page.Surface;
  176.   FolderTreeView.Directory := ExpandConstant('{src}');
  177.   { TBitmapImage }
  178.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapImage');
  179.   BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
  180.   ExtractTemporaryFile(ExtractFileName(BitmapFileName));
  181.   BitmapImage := TBitmapImage.Create(Page);
  182.   BitmapImage.AutoSize := True;
  183.   BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
  184.   BitmapImage.Parent := Page.Surface;
  185.   BitmapImage2 := TBitmapImage.Create(Page);
  186.   BitmapImage2.BackColor := $400000;
  187.   BitmapImage2.Bitmap := BitmapImage.Bitmap;
  188.   BitmapImage2.Center := True;
  189.   BitmapImage2.Left := BitmapImage.Width + 10;
  190.   BitmapImage2.Height := 2*BitmapImage.Height;
  191.   BitmapImage2.Width := 2*BitmapImage.Width;
  192.   BitmapImage2.Parent := Page.Surface;
  193.   BitmapImage3 := TBitmapImage.Create(Page);
  194.   BitmapImage3.Bitmap := BitmapImage.Bitmap;
  195.   BitmapImage3.Stretch := True;
  196.   BitmapImage3.Left := 3*BitmapImage.Width + 20;
  197.   BitmapImage3.Height := 4*BitmapImage.Height;
  198.   BitmapImage3.Width := 4*BitmapImage.Width;
  199.   BitmapImage3.Parent := Page.Surface;
  200.   { TRichViewer }
  201.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TRichViewer');
  202.   RichEditViewer := TRichEditViewer.Create(Page);
  203.   RichEditViewer.Width := Page.SurfaceWidth;
  204.   RichEditViewer.Height := Page.SurfaceHeight;
  205.   RichEditViewer.Parent := Page.Surface;
  206.   RichEditViewer.ScrollBars := ssVertical;
  207.   RichEditViewer.UseRichEdit := True;
  208.   RichEditViewer.RTFText := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue128;}\viewkind4\uc1\pard\f0\fs20 T\cf1 Rich\cf2 Edit\cf3 Viewer\cf0\par}';
  209.   RichEditViewer.ReadOnly := True;
  210. procedure AboutButtonOnClick(Sender: TObject);
  211. begin
  212.   MsgBox('This demo shows some features of the WizardForm object and the various VCL classes.', mbInformation, mb_Ok);
  213. procedure URLLabelOnClick(Sender: TObject);
  214.   ErrorCode: Integer;
  215. begin
  216.   ShellExec('open', 'http://www.innosetup.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
  217. procedure InitializeWizard();
  218.   AboutButton, CancelButton: TButton;
  219.   URLLabel: TNewStaticText;
  220.   BackgroundBitmapImage: TBitmapImage;
  221.   BackgroundBitmapText: TNewStaticText;
  222. begin
  223.   { Custom wizard pages }
  224.   CreateTheWizardPages;
  225.   { Other custom controls }
  226.   CancelButton := WizardForm.CancelButton;
  227.   AboutButton := TButton.Create(WizardForm);
  228.   AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
  229.   AboutButton.Top := CancelButton.Top;
  230.   AboutButton.Width := CancelButton.Width;
  231.   AboutButton.Height := CancelButton.Height;
  232.   AboutButton.Caption := '&About...';
  233.   AboutButton.OnClick := @AboutButtonOnClick;
  234.   AboutButton.Parent := WizardForm;
  235.   URLLabel := TNewStaticText.Create(WizardForm);
  236.   URLLabel.Caption := 'www.innosetup.com';
  237.   URLLabel.Cursor := crHand;
  238.   URLLabel.OnClick := @URLLabelOnClick;
  239.   URLLabel.Parent := WizardForm;
  240.   { Alter Font *after* setting Parent so the correct defaults are inherited first }
  241.   URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
  242.   URLLabel.Font.Color := clBlue;
  243.   URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
  244.   URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
  245.   BackgroundBitmapImage := TBitmapImage.Create(MainForm);
  246.   BackgroundBitmapImage.Left := 50;
  247.   BackgroundBitmapImage.Top := 100;
  248.   BackgroundBitmapImage.AutoSize := True;
  249.   BackgroundBitmapImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
  250.   BackgroundBitmapImage.Parent := MainForm;
  251.   BackgroundBitmapText := TNewStaticText.Create(MainForm);
  252.   BackgroundBitmapText.Left := BackgroundBitmapImage.Left;
  253.   BackgroundBitmapText.Top := BackgroundBitmapImage.Top + BackgroundBitmapImage.Height + ScaleY(8);
  254.   BackgroundBitmapText.Caption := 'TBitmapImage';
  255.   BackgroundBitmapText.Parent := MainForm;
  256.